package wang.hex.codetransfer.image;

import javax.swing.*;
import java.awt.*;

/**
 * @Author wujie
 * @Class GUIUtil
 * @Description
 * @Date 2021/1/6 10:01
 */
public class ImageGui {
    private JFrame frame;
    private ImagePanel panel;

    private ImageGui(int x, int y, int width, int height) {
        frame = new JFrame("");
        panel = new ImagePanel(null);

        frame.setAlwaysOnTop(true);
        frame.setUndecorated(true);
        panel.setBounds(20, 20, width, height);
        frame.add(panel);
        Container contentPane = frame.getContentPane();
        contentPane.setBackground(Color.white);
        frame.setBounds(x, y, width , height );
        frame.setVisible(true);


    }

    public static ImageGui of(int x, int y, int width, int height) {
        return new ImageGui(x, y, width, height);
    }

    public void setImage(Image img) {
        panel.changeImage(img);

    }

}
